package com.example.service.impl;

import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import com.example.entity.Customer;
import com.example.mapper.CustomerMapper;
import com.example.service.CustomerService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerMapper mapper;
    @Override
    public Customer getById(Integer custId) {
        return mapper.selectById(custId);
    }

    @Override
    @GlobalTransactional
    public void testrollback() {
        Customer customer=new Customer();
        customer.setCustId(1);
        customer.setCustName("zj1");
        mapper.update(customer,null);
        int a=10/0;
        Customer customer1=new Customer();
        customer1.setCustId(2);
        customer1.setCustName("zj2");
        customer1.setCustEmail("111");
        mapper.insert(customer);
    }

}
